const { Router } = require('express');
const router = Router();
const cartController = require('../controllers/cartController')
const { authenticate, verifiedOnly } = require('../middlewares/auth')

// 检查购物车状态 - 不需要认证，任何人都可以检查购物车功能是否可用
router.get('/status', cartController.checkStatus)

// 获取购物车列表
router.get('/', authenticate, cartController.getCartItems)

// 添加商品到购物车
router.post('/', authenticate, verifiedOnly, cartController.addToCart)

// 从购物车移除商品
router.delete('/:id', authenticate, cartController.removeFromCart)

// 清空购物车
router.delete('/', authenticate, cartController.clearCart)

// 批量结算购物车
router.post('/checkout', authenticate, verifiedOnly, cartController.checkout)

module.exports = router